package yunquan.wang.modules.base.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import yunquan.wang.base.domain.Comment;
import yunquan.wang.base.domain.IdEntity;

/**
 * @author calvin
 */
@Entity
@Table(name = "base_userbasic")
public class UserBasic extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5666028763146017893L;
	@Column(name = "loginname",length=50)
    @Comment("登录名")
	private String loginName;// 
	 @Column(name="password",length=50)
	 @Comment(value="密码",export=false)
	private String password;// 为简化演示使用明文保存的密码
	 @Column(name="name",length=30)
	 @Comment("姓名")
	private String name;// 姓名
	 @Column(name="email",length=50)
	@Comment("邮件")
	private String email;// email
	 @Column(name="enabled",length=1)
	@Comment(value="是否可用",pattern=Comment.CODE_TYPE+"yesorno")
	private Boolean enabled = false;// 可用
	@Column(name = "locked",length=1)
	@Comment(value="是否锁定",pattern=Comment.CODE_TYPE+"accountLocked")
	private Boolean accountNonLocked;// 账号被锁定
	@Column(name = "online",length=1)
	
	@Comment(value="是否在线",export=false)
	private Boolean isOnline;
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userBasic")
	private Set<Userinfo> userinfos=new HashSet<Userinfo>(0);//用户详细信息
    
    @ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY)  
    @JoinTable(name = "base_user_roles", inverseJoinColumns = @JoinColumn(name = "role_id"), joinColumns = @JoinColumn(name = "user_id"))
  
    private Set<Rolesinfo> rolesinfos=new HashSet<Rolesinfo>(0);
    
    @ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "position_id" )
    private Position position;//行政职务
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "group_id")
	private   GroupInfo groupInfo;

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public Boolean getAccountNonLocked() {
		return accountNonLocked;
	}

	public void setAccountNonLocked(Boolean accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}

	public Boolean getIsOnline() {
		return isOnline;
	}

	public void setIsOnline(Boolean isOnline) {
		this.isOnline = isOnline;
	}

	public Set<Userinfo> getUserinfos() {
		return userinfos;
	}

	public void setUserinfos(Set<Userinfo> userinfos) {
		this.userinfos = userinfos;
	}

	public Set<Rolesinfo> getRolesinfos() {
		return rolesinfos;
	}

	public void setRolesinfos(Set<Rolesinfo> rolesinfos) {
		this.rolesinfos = rolesinfos;
	}

	public Position getPosition() {
		return position;
	}

	public void setPosition(Position position) {
		this.position = position;
	}

	public GroupInfo getGroupInfo() {
		return groupInfo;
	}

	public void setGroupInfo(GroupInfo groupInfo) {
		this.groupInfo = groupInfo;
	}
 
 
	
}